//912
//归并
class Solution {
    public int[] sortArray(int[] nums) {
        guibingSort(nums, 0, nums.length-1);
        return nums;
    }

    private void guibingSort(int[] nums, int l, int r) {
        if (l >= r) {
            return;
        }
        int mid = (l+r)/2;
        guibingSort(nums, l, mid);
        guibingSort(nums, mid+1, r);
        sort(nums, l, mid+1, r);
    }
    
    private void sort(int[] nums, int l, int mid, int r) {
        int a1 = l;
        int a2 = mid;
        int[] arr = new int[r-l+1];
        int i = 0;
        while (a1 < mid && a2 <= r) {
            if (nums[a1] < nums[a2]) {
                arr[i++] = nums[a1++];
            }
            else {
                arr[i++] = nums[a2++];
            }
        }
        while (a1 < mid) {
            arr[i++] = nums[a1++];
        }
        while (a2 <= r) {
            arr[i++] = nums[a2++];
        }
        i = 0;
        for (;i < arr.length; i++) {
            nums[l++] = arr[i];
        }
    }    
}
//快排
class Solution {
    public int[] sortArray(int[] nums) {
        quiltySort(nums, 0, nums.length-1);
        return nums;
    }

    public void quiltySort(int[] nums, int l, int r) {
        if (l >= r) {
            return;
        }
        //利用三数取中法优化
        int m = mid(nums, l, r);
        sweap(nums, l, m);
        m = sort(nums, l+1, r);
        quiltySort(nums, l, m-1);
        quiltySort(nums, m+1, r);
    }

    private int sort(int[] nums, int l, int r) {
        int tmp = nums[l-1];
        int i = l-1;
        while (l < r) {
            while (l < r && tmp < nums[r]) {
                r--;
            }
            while (l < r && tmp >= nums[l]) {
                l++;
            }
            sweap(nums, l, r);
        }
        if (nums[l] < nums[i]) {
            sweap(nums, i, l);
        }
        return l;
    }

    public void sweap(int[] nums, int l, int r) {
        int tmp = nums[l] ^ nums[r];
        nums[l] = tmp ^ nums[l];
        nums[r] = tmp ^ nums[l];
    }

    private int mid(int[] nums, int l, int r) {
        if (nums[l] < nums[r]) {
            return nums[(l+r)/2] < nums[l] ? l : (nums[r] < nums[(l+r)/2] ? r : (l+r)/2);
        }
        else {
            return nums[(l+r)/2] < nums[l] ? (nums[r] > nums[(l+r)/2] ? r : (l+r)/2) : l;
        }
    }
}

class Solution {

    public int maxAreaOfIsland(int[][] grid) {
        int maxBig = 0;
        int row = grid.length;
        int col = grid[0].length;
        Queue<int[]> queue = new LinkedList<>();
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < col; j++) {
                if (grid[i][j] == 1) {
                    grid[i][j] = 0;
                    int count = 0;
                    queue.offer(new int[]{i, j});
                    while (!queue.isEmpty()) {
                        int arr[] = queue.poll();
                        count++;
                        int x = arr[0];
                        int y = arr[1];
                        if (x+1 < row && grid[x+1][y] == 1) {
                            queue.offer(new int[]{x+1,y});
                            grid[x+1][y] = 0;
                        }
                        if (x-1 >= 0 && grid[x-1][y] == 1) {
                            queue.offer(new int[]{x-1,y});
                            grid[x-1][y] = 0;
                        }
                        if (y+1 < col && grid[x][y+1] == 1) {
                            queue.offer(new int[]{x,y+1});
                            grid[x][y+1] = 0;
                        }
                        if (y-1 >= 0 && grid[x][y-1] == 1) {
                            queue.offer(new int[]{x,y-1});
                            grid[x][y-1] = 0;
                        }
                        
                    }
                    if (maxBig < count) {
                        maxBig = count;
                    }
                }
            }
        }
        return maxBig;
    }
}
//DP35
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int m = in.nextInt();
        int q = in.nextInt();
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (i == 0 && j == 0) {
                    arr[i][j] = in.nextLong();
                }
                else if (i == 0) {
                    arr[i][j] = in.nextLong() + arr[i][j-1];
                }
                else if (j == 0) {
                    arr[i][j] = in.nextLong() + arr[i-1][j];
                }
                else {
                    arr[i][j] = in.nextLong() - arr[i-1][j-1] + 
                    arr[i-1][j] + arr[i][j-1];
                }
            }
        }

        for (int i = 0; i < q; i++) {
            int x1 = in.nextInt()-1;
            int y1 = in.nextInt()-1;
            int x2 = in.nextInt()-1;
            int y2 = in.nextInt()-1;
            if (x1 == 0 && y1 == 0) {
                System.out.println(arr[x2][y2]);
            }
            else if (x1 == 0) {
                System.out.println(arr[x2][y2]-arr[x2][y1-1]);
            }
            else if (y1 == 0) {
                System.out.println(arr[x2][y2]-arr[x1-1][y2]);
            }
            else {
                System.out.println(arr[x2][y2]-arr[x2][y1-1]-arr[x1-1][y2]+arr[x1-1][y1-1]);
            }
        }
    }
}

